#ifndef __DRV_SAMPLE_CORE_H__
#define __DRV_SAMPLE_CORE_H__

#include "char_dev.h"
#include "sys_types.h"
#include "oal.h"
extern const dev_description_t g_sample_dev_description;

typedef enum {
    /* HENC IRQ */
    EVENT_HENC_FRAME_IRQ = 0x10,
    EVENT_HENC_PKT_IRQ = 0x11,
    /* JENC IRQ */
    EVENT_JENC_FRAME_IRQ = 0x20,
    EVENT_JENC_PKT_IRQ = 0x21,
} smaple_fasync_event_t;

//write type
typedef enum {
    DVP_WRITE_DMA,
} sample_write_type;

//read type
typedef enum {
    JPAG_HEAD,
} sample_read_type;

enum driver_sample_ioctl_cmd {
    /* HENC */
    SAMPLE_ENABLE,
    SAMPLE_HENC_ENABLE,
    SAMPLE_HENC_MALLOC,
    SMAPLE_HENC_FREE,
    /* JENC */
    SAMPLE_JENC_ENABLE,
    SAMPLE_JENC_MALLOC,
    SMAPLE_JENC_FREE,
};

typedef struct {
    uint8_t* addr;
    uint32_t len;
    uint32_t ram_id;
} smaple_mm_t;

//write param
typedef struct {
    sample_write_type write_type;
} driver_sample_write_t;

//read param
typedef struct {
    sample_read_type read_type;
} driver_sample_read_t;

typedef struct {
    int  en_width;
    int  en_hight;
    int  en_frame_nums;
    int  en_iprop;
    int  en_iqp_val;

    int  en_p_max_scale; // 0x78
    int  en_p_min_scale;
    int  en_p_max;
    int  en_g_kernel_size; // 0x7c
    int  en_key_max;
    int  en_up_max;
    int  en_dw_min;

    int  en_nal_header_en; //0x38
    int  en_nal_header_len;
    int  en_qmap_en;//0x30
    int  en_qp_len;//0x40
	int  dst_fps;
	int  bit_rate;
	int  stat_time;
	int clip_qp_max;
	int clip_qp_min;
	int  dbg_mode;
} driver_sample_henc_param;

typedef struct {
    int  width;
    int  hight;
    int  yuv_mode;
    int  qp_reload;
    uint8_t payload[480];
} driver_sample_jenc_param;

typedef struct {
    int  width;
    int  hight;
    int  yuv_mode;
    int  inputsrc; //0-camera 1-gui
} driver_sample_dvp_param;


typedef struct {
    driver_sample_henc_param henc_param;
    driver_sample_jenc_param* jenc_param;
    driver_sample_dvp_param dvp_param;
    void (*sample_henc_pkt_irq_cb)(void);
    void (*sample_henc_frame_irq_cb)(void);
    void (*sample_jenc_pkt_irq_cb)(void);
    void (*sample_jenc_frame_irq_cb)(void);
} driver_sample_open_opt_t;

typedef struct {
    file_operations_t fops;
    driver_sample_open_opt_t sample_dev;
    bool henc_used;
    bool jenc_used;
    OAL_QUEUE henc_queue;
    OAL_QUEUE jenc_queue;
    char* jpeg_header;
    uint16_t jpeg_header_length;
} drv_sample_fops;
#endif
